<?php
mysql_query("SET character_set_results=utf8");
class User_model extends CI_Model {

    private $tbl_login= 'login';

    function __construct(){
        parent::__construct();
    }

    function list_all(){
        $this->db->order_by('id_user','asc');
        return $this->db->get($tbl_login);
    }

    function count_all(){
        return $this->db->count_all($this->tbl_login);
    }

    function get_paged_list($limit = 10, $offset = 0){
        $this->db->order_by('id_user','asc');
        return $this->db->get($this->tbl_login, $limit, $offset);
    }

    function get_by_id($id){
        $this->db->where('id_user', $id);
        return $this->db->get($this->tbl_login);
    }

    function save($data){
        $this->db->insert($this->tbl_login, $data);
        return $this->db->insert_id();
    }

    function update($id_user, $data){
        $this->db->where('id_user', $id_user);
        $this->db->update($this->tbl_login, $data);
    }

    function delete($id_user){
        $this->db->where('id_user', $id_user);
        $this->db->delete($this->tbl_login);
    }
}
?>